<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=iso-8859-1" />
    <title>
      DHCP-4.4.2
    </title>
    <link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
  </head>
  <body class="blfs" id="blfs-2020-04-02">
    <div class="navheader">
      <h4>
        Beyond Linux<sup>�</sup> From Scratch <span class="phrase">(System
        V</span> Edition) - Version 2020-04-02
      </h4>
      <h3>
        Chapter&nbsp;14.&nbsp;Connecting to a Network
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="dhcpcd.html" title="dhcpcd-8.1.6">Prev</a>
          <p>
            dhcpcd-8.1.6
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="netprogs.html" title=
          "Networking Programs">Next</a>
          <p>
            Networking Programs
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="connect.html" title=
          "Chapter&nbsp;14.&nbsp;Connecting to a Network">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="dhcp" name="dhcp"></a>DHCP-4.4.2
      </h1>
      <div class="package" lang="en" xml:lang="en">
        <h2 class="sect2">
          Introduction to ISC DHCP
        </h2>
        <p>
          The <span class="application">ISC DHCP</span> package contains both
          the client and server programs for DHCP. <span class=
          "command"><strong>dhclient</strong></span> (the client) is used for
          connecting to a network which uses DHCP to assign network
          addresses. <span class="command"><strong>dhcpd</strong></span> (the
          server) is used for assigning network addresses on private
          networks.
        </p>
        <p>
          This package is known to build and work properly using an LFS-9.1
          platform.
        </p>
        <h3>
          Package Information
        </h3>
        <div class="itemizedlist">
          <ul class="compact">
            <li class="listitem">
              <p>
                Download (FTP): <a class="ulink" href=
                "ftp://ftp.isc.org/isc/dhcp/4.4.2/dhcp-4.4.2.tar.gz">ftp://ftp.isc.org/isc/dhcp/4.4.2/dhcp-4.4.2.tar.gz</a>
              </p>
            </li>
            <li class="listitem">
              <p>
                Download MD5 sum: 2afdaf8498dc1edaf3012efdd589b3e1
              </p>
            </li>
            <li class="listitem">
              <p>
                Download size: 9.4 MB
              </p>
            </li>
            <li class="listitem">
              <p>
                Estimated disk space required: 115 MB
              </p>
            </li>
            <li class="listitem">
              <p>
                Estimated build time: 0.4 SBU
              </p>
            </li>
          </ul>
        </div>
        <p class="usernotes">
          User Notes: <a class="ulink" href=
          "http://wiki.linuxfromscratch.org/blfs/wiki/dhcp">http://wiki.linuxfromscratch.org/blfs/wiki/dhcp</a>
        </p>
      </div>
      <div class="kernel" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="dhcp-kernel" name="dhcp-kernel"></a>Kernel Configuration
        </h2>
        <p>
          You must have Packet Socket support. IPv6 support is optional.
        </p>
        <pre class="screen">
<code class="literal">[*] Networking support ---&gt;        [CONFIG_NET]
      Networking options ---&gt;
        &lt;*&gt; Packet socket          [CONFIG_PACKET]
        &lt;*&gt; The IPv6 Protocol ---&gt; [CONFIG_IPV6]</code>
</pre>
      </div>
      <div class="installation" lang="en" xml:lang="en">
        <h2 class="sect2">
          Installation of ISC DHCP
        </h2>
        <div class="admon note">
          <img alt="[Note]" src="../images/note.png" />
          <h3>
            Note
          </h3>
          <p>
            This package does not support parallel build.
          </p>
        </div>
        <div class="admon note">
          <img alt="[Note]" src="../images/note.png" />
          <h3>
            Note
          </h3>
          <p>
            Be careful with the instructions below. The single and double
            quotes are important because the defined variables are used
            verbatim in the code.
          </p>
        </div>
        <p>
          Install <span class="application">ISC DHCP</span> by running the
          following commands:
        </p>
        <pre class="userinput">
<kbd class=
"command">( export CFLAGS="$CFLAGS -Wall -fno-strict-aliasing                 \
        -D_PATH_DHCLIENT_SCRIPT='\"/sbin/dhclient-script\"'         \
        -D_PATH_DHCPD_CONF='\"/etc/dhcp/dhcpd.conf\"'               \
        -D_PATH_DHCLIENT_CONF='\"/etc/dhcp/dhclient.conf\"'"        &amp;&amp;

./configure --prefix=/usr                                           \
            --sysconfdir=/etc/dhcp                                  \
            --localstatedir=/var                                    \
            --with-srv-lease-file=/var/lib/dhcpd/dhcpd.leases       \
            --with-srv6-lease-file=/var/lib/dhcpd/dhcpd6.leases     \
            --with-cli-lease-file=/var/lib/dhclient/dhclient.leases \
            --with-cli6-lease-file=/var/lib/dhclient/dhclient6.leases
) &amp;&amp;
make -j1</kbd>
</pre>
        <p>
          This package does not come with a test suite.
        </p>
        <p>
          If you only want to install the <span class="application">ISC
          DHCP</span> client, issue the following commands as the
          <code class="systemitem">root</code> user:
        </p>
        <pre class="root">
<kbd class="command">make -C client install         &amp;&amp;
mv -v /usr/sbin/dhclient /sbin &amp;&amp;
install -v -m755 client/scripts/linux /sbin/dhclient-script</kbd>
</pre>
        <p>
          Skip to <a class="xref" href="dhcp.html#dhclient-config" title=
          "Client Configuration">the section called &ldquo;Client
          Configuration&rdquo;</a> in order to configure the client
        </p>
        <p>
          If you only want to install the <span class="application">ISC
          DHCP</span> server, issue the following command as the <code class=
          "systemitem">root</code> user:
        </p>
        <pre class="root">
<kbd class="command">make -C server install</kbd>
</pre>
        <p>
          Skip to <a class="xref" href="dhcp.html#dhcpd-config" title=
          "Server Configuration">the section called &ldquo;Server
          Configuration&rdquo;</a> in order to configure the server.
        </p>
        <p>
          Alternatively, you can install whole package which includes the
          client, server, relay, static libraries and development headers by
          running the following commands as the <code class=
          "systemitem">root</code> user:
        </p>
        <pre class="root">
<kbd class="command">make install                   &amp;&amp;
mv -v /usr/sbin/dhclient /sbin &amp;&amp;
install -v -m755 client/scripts/linux /sbin/dhclient-script</kbd>
</pre>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          Configuring ISC DHCP
        </h2>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3">
            <a id="dhcp-config" name="dhcp-config"></a>
          </h3>
          <h4 class="title">
            <a id="dhcp-config" name="dhcp-config"></a>Config Files
          </h4>
          <p>
            <code class="filename">/etc/dhcp/dhclient.conf</code> and
            <code class="filename">/etc/dhcp/dhcpd.conf</code>
          </p>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3">
            <a id="dhclient-config" name="dhclient-config"></a>
          </h3>
          <h4 class="title">
            <a id="dhclient-config" name="dhclient-config"></a>Client
            Configuration
          </h4>
          <p>
            Create a basic <code class=
            "filename">/etc/dhcp/dhclient.conf</code> by running the
            following command as the <code class="systemitem">root</code>
            user:
          </p>
          <pre class="root">
<kbd class="command">install -vdm755 /etc/dhcp &amp;&amp;
cat &gt; /etc/dhcp/dhclient.conf &lt;&lt; "EOF"
<code class="literal"># Begin /etc/dhcp/dhclient.conf
#
# Basic dhclient.conf(5)

#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        netbios-name-servers, netbios-scope, interface-mtu,
        ntp-servers;
require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;

# End /etc/dhcp/dhclient.conf</code>
EOF</kbd>
</pre>
          <p>
            See <span class="command"><strong>man 5
            dhclient.conf</strong></span> for additional options.
          </p>
          <p>
            Now create the <code class="filename">/var/lib/dhclient</code>
            directory which will contain DHCP Client leases by running the
            following command as the <code class="systemitem">root</code>
            user:
          </p>
          <pre class="root">
<kbd class="command">install -v -dm 755 /var/lib/dhclient</kbd>
</pre>
          <p>
            At this point you can test if <span class=
            "command"><strong>dhclient</strong></span> is behaving as
            expected by running the following command as the <code class=
            "systemitem">root</code> user:
          </p>
          <pre class="root">
<kbd class="command">dhclient <em class=
"replaceable"><code>&lt;eth0&gt;</code></em></kbd>
</pre>
          <p>
            Replace <em class="replaceable"><code>&lt;eth0&gt;</code></em>
            with your desired interface. If you want more verbose output, add
            the <span class="command"><strong>-v</strong></span> parameter to
            the command above.
          </p>
          <p>
            <a id="dhclient-service" name="dhclient-service"></a> If you want
            to configure network interfaces at boot using <span class=
            "command"><strong>dhclient</strong></span>, you need to install
            the <code class="filename">/lib/services/dhclient</code> script
            included in <a class="xref" href=
            "../introduction/bootscripts.html" title=
            "BLFS Boot Scripts">blfs-bootscripts-20191204</a> package:
          </p>
          <pre class="root">
<kbd class="command">make install-service-dhclient</kbd>
</pre>
          <p>
            <a id="dhclient-ifconfig" name="dhclient-ifconfig"></a> Next,
            create the <code class=
            "filename">/etc/sysconfig/ifconfig.eth0</code> configuration file
            with the following commands as the <code class=
            "systemitem">root</code> user:
          </p>
          <pre class="root">
<kbd class="command">cat &gt; /etc/sysconfig/ifconfig.eth0 &lt;&lt; "EOF"
<code class="literal">ONBOOT="yes"
IFACE="eth0"
SERVICE="dhclient"
DHCP_START=""
DHCP_STOP=""

# Set PRINTIP="yes" to have the script print
# the DHCP assigned IP address
PRINTIP="no"

# Set PRINTALL="yes" to print the DHCP assigned values for
# IP, SM, DG, and 1st NS. This requires PRINTIP="yes".
PRINTALL="no"</code>
EOF</kbd>
</pre>
          <p>
            Adjust the file to suit your needs.
          </p>
          <p>
            For more information on the appropriate <code class=
            "envar">DHCP_START</code> and <code class=
            "envar">DHCP_STOP</code> values see <span class=
            "command"><strong>man 8 dhclient</strong></span>.
          </p>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3">
            <a id="dhcpd-config" name="dhcpd-config"></a>
          </h3>
          <h4 class="title">
            <a id="dhcpd-config" name="dhcpd-config"></a>Server Configuration
          </h4>
          <p>
            Note that you only need the DHCP server if you want to issue LAN
            addresses over your network. The DHCP client doesn't need the
            server in order to function properly.
          </p>
          <p>
            Start with creating <code class=
            "filename">/etc/dhcp/dhcpd.conf</code> by running the following
            command as the <code class="systemitem">root</code> user:
          </p>
          <pre class="root">
<kbd class="command">cat &gt; /etc/dhcp/dhcpd.conf &lt;&lt; "EOF"
<code class="literal"># Begin /etc/dhcp/dhcpd.conf
#
# Example dhcpd.conf(5)

# Use this to enable / disable dynamic dns updates globally.
ddns-update-style none;

# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

# This is a very basic subnet declaration.
subnet 10.254.239.0 netmask 255.255.255.224 {
  range 10.254.239.10 10.254.239.20;
  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
}

# End /etc/dhcp/dhcpd.conf</code>
EOF</kbd>
</pre>
          <p>
            Adjust the file to suit your needs. See <span class=
            "command"><strong>man 5 dhcpd.conf</strong></span> for additional
            options.
          </p>
          <p>
            Now create the <code class="filename">/var/lib/dhcpd</code>
            directory which will contain DHCP Server leases by running the
            following command as the <code class="systemitem">root</code>
            user:
          </p>
          <pre class="root">
<kbd class="command">install -v -dm 755 /var/lib/dhcpd</kbd>
</pre>
          <p>
            If you want to start the DHCP Server at boot, install the
            <span class="phrase"><code class=
            "filename">/etc/rc.d/init.d/dhcpd</code> inti script</span>
            included in the <a class="xref" href=
            "../introduction/bootscripts.html" title=
            "BLFS Boot Scripts">blfs-bootscripts-20191204</a> package:
          </p>
          <pre class="root">
<kbd class="command">make install-dhcpd</kbd>
</pre>
          <p>
            You will need to edit the <span class="phrase"><code class=
            "filename">/etc/sysconfig/dhcpd</code></span> in order to set the
            interface on which <span class=
            "command"><strong>dhcpd</strong></span> will serve the DHCP
            requests.
          </p>
        </div>
      </div>
      <div class="content" lang="en" xml:lang="en">
        <h2 class="sect2">
          Contents
        </h2>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong class="segtitle">Installed Programs:</strong>
              <span class="segbody">dhclient, dhclient-script, dhcpd,
              dhcrelay and omshell</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Installed Libraries:</strong>
              <span class="segbody">libdhcpctl.a and libomapi.a</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Installed Directories:</strong>
              <span class="segbody">/etc/dhcp, /usr/include/dhcpctl,
              /usr/include/isc-dhcp, /usr/include/omapip, /var/lib/dhclient
              and /var/lib/dhcpd</span>
            </div>
          </div>
        </div>
        <div class="variablelist">
          <h3>
            Short Descriptions
          </h3>
          <table border="0" class="variablelist">
            <colgroup>
              <col align="left" valign="top" />
              <col />
            </colgroup>
            <tbody>
              <tr>
                <td>
                  <p>
                    <a id="dhclient" name="dhclient"></a><span class=
                    "term"><span class=
                    "command"><strong>dhclient</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is the implementation of the DHCP client.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="dhclient-script" name=
                    "dhclient-script"></a><span class="term"><span class=
                    "command"><strong>dhclient-script</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is used by dhclient to (re)configure interfaces. It can
                    make extra changes by invoking custom
                    dhclient-{entry,exit}-hooks.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="dhcpd" name="dhcpd"></a><span class=
                    "term"><span class=
                    "command"><strong>dhcpd</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    implements Dynamic Host Configuration Protocol (DHCP) and
                    Internet Bootstrap Protocol (BOOTP) requests for network
                    addresses.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="dhcrelay" name="dhcrelay"></a><span class=
                    "term"><span class=
                    "command"><strong>dhcrelay</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    provides a means to accept DHCP and BOOTP requests on a
                    subnet without a DHCP server and relay them to a DHCP
                    server on another subnet.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="omshell" name="omshell"></a><span class=
                    "term"><span class=
                    "command"><strong>omshell</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    provides an interactive way to connect to, query and
                    possibly change the ISC DHCP Server's state via OMAPI,
                    the Object Management API.
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <p class="updated">
        Last updated on 2020-02-21 11:11:06 -0600
      </p>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="dhcpcd.html" title="dhcpcd-8.1.6">Prev</a>
          <p>
            dhcpcd-8.1.6
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="netprogs.html" title=
          "Networking Programs">Next</a>
          <p>
            Networking Programs
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="connect.html" title=
          "Chapter&nbsp;14.&nbsp;Connecting to a Network">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
  </body>
</html>
